// house_pkg/pages/room/index.ts
Page({
  data: {
    point: '',
    building: '',
    rooms: []
  },
  onLoad({ point, building }) {
    // console.log(point, building);
    this.fake(point, building)
  },
  fake(point, building) {
    const rooms = []
    // 生成随机数，来决定要显示的房间数量
    const size = Math.floor(Math.random() * 4) + 4
    for (let i = 0; i < size; i++) {
      // 房间号 = 楼层 + 0 + 编号
      // 生成楼层（1-20）
      let floor = Math.floor(Math.random() * 20) + 1
      // 生成编号(1-6)
      let num = Math.floor(Math.random() * 6) + 1
      // 生成房间号
      let room = [floor + 0 + num].join('')
      if (!rooms.includes(room)) {
        rooms.push(room)
      }
    }
    this.setData({
      point,
      building,
      rooms
    })
  },
  goForm(ev) {
    wx.navigateTo({
      url: `/house_pkg/pages/form/index?point=${this.data.point}&building=${this.data.building}&room=${ev.mark.room}`,
    })
  },
})